import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import qiankun from 'vite-plugin-qiankun'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    // vueDevTools(),
    qiankun('sub1-app', {
      useDevMode: true,
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  server: {
    port: 8182,
    cors: true,
    headers: {
      'Access-Control-Allow-Origin': '*',
    },
    // proxy: proxy.proxyTable,
    watch:{
      ignored:['**/*.js', '**/*.css'], // 忽略对 .js 和 .css 文件的监听
    },
    hmr: {
      overlay: false, // 关闭热更新提示
    },
  },
  base: '/sub1-app/', // 关键配置：与主应用entry路径保持一致
  build: {
    outDir: 'dist/sub1-app', // 打包输出到子目录
  }
})
